﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace HZ.Supervise.Web.Secondphase
{
    public partial class ReportOfcentralizePurchasListThree : BasePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

       
            
        /// <summary>
        /// 行创建时 合并表头
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void gvwStorage_RowCreated(object sender, GridViewRowEventArgs e)
        {
            switch (e.Row.RowType)
            {
                case DataControlRowType.Header:

                    //取得下拉框的月份


                    //第一行表头
                    TableCellCollection tcHeader = e.Row.Cells;
                    tcHeader.Clear();
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[0].Attributes.Add("rowspan", "2"); //跨Row
                    tcHeader[0].Attributes.Add("bgcolor", "LightSteelBlue");
                    //tcHeader[0].Attributes.Add("bgcolor", "white");
                    tcHeader[0].Text = "所属区域";

                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[1].Attributes.Add("colspan", "3"); //跨Column
                    tcHeader[1].Text = "合计";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[2].Attributes.Add("colspan", "2"); //跨Column
                    tcHeader[2].Text = "医院";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[3].Attributes.Add("colspan", "2"); //跨Column
                    tcHeader[3].Text = "卫生院";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[4].Attributes.Add("colspan", "2"); //跨Column
                    tcHeader[4].Text = "社区卫生机构</th></tr><tr>";

                    //第2行表头
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[5].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[5].Text = "实际参加采购数";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[6].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[6].Text = "应参加采购数";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[7].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[7].Text = "参加比例(%)";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[8].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[8].Text = "实际参加采购数";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[9].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[9].Text = "应参加采购数";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[10].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[10].Text = "实际参加采购数";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[11].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[11].Text = "应参加采购数";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[12].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[12].Text = "实际参加采购数";
                    tcHeader.Add(new TableHeaderCell());
                    tcHeader[13].Attributes.Add("bgcolor", "Khaki");
                    tcHeader[13].Text = "应参加采购数</th></tr><tr>";
                    break;
            }
        }

        protected void gvwStorage_RowDataBound(object sender, GridViewRowEventArgs e)
        {
            if (e.Row.RowIndex >= 0)
            {
                double sum1 = (Convert.ToDouble(e.Row.Cells[4].Text) + Convert.ToDouble(e.Row.Cells[6].Text) + Convert.ToDouble(e.Row.Cells[8].Text));
                double sum2 = (Convert.ToDouble(e.Row.Cells[5].Text) + Convert.ToDouble(e.Row.Cells[7].Text) + Convert.ToDouble(e.Row.Cells[9].Text));
                
                e.Row.Cells[2].Text = sum1.ToString();
                e.Row.Cells[3].Text = sum2.ToString();
                e.Row.Cells[4].Text = (sum1/sum2).ToString()+"&";
            }
        }

        /// <summary>
        /// 到处Excel
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        protected void btnSent_Click(object sender, EventArgs e)
        {

        }

        protected void btnQuery_Click(object sender, EventArgs e)
        {
        }
        
    }
}
